import Vue from 'vue'
import App from './App'
// // 自定义插件
import MyHttp from './core/http/index.js'
import MyStore from './core/store/index'
import MyUtils from './core/untils/index'
import MyCatch from './core/cache/index'
import MyConfig from './core/config/index'
import MyAuth from './core/auth/index'
import MyUserLogin from './core/login'
// import {updateurl} from './common/base.js'
import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue"
import MescrollUni from "@/components/mescroll-uni/mescroll-uni.vue"

App.mpType = 'app'

//微信h5授权登录时使用此代码
import RouterMount from '@/core/http/useRouter.js'
import routerLink from '@/core/http/router-link.vue' 
// Vue.component('router-link', routerLink)
// #ifdef H5
if(MyConfig.mode == 1){
	Vue.component('router-link', routerLink)
}
// #endif

Vue.component('mescroll-body', MescrollBody)
Vue.component('mescroll-uni', MescrollUni)
Vue.prototype.$store = MyStore

// Vue.prototype.$myStore = MyStore // vuex store
Vue.prototype.$myHttp = MyHttp // http
Vue.prototype.$myUtils = MyUtils // utils, 包含表单验证、错误处理、页面跳转、消息提示
Vue.prototype.$myCatch = MyCatch // catch
Vue.prototype.$myConfig = MyConfig // config
Vue.prototype.$myUserLogin = MyUserLogin // MyUserLogin
Vue.prototype.$myAuth = MyAuth

// Vue.prototype.$updateurl = updateurl;
// 自定义指令用于试图元素的权限验证
Vue.directive('auth', {
    inserted: (el, binding, vnode) => {
        if (!MyAuth.checkPermission(binding.value)) {
            if (vnode.elm.parentNode) {
                vnode.elm.parentNode.removeChild(el)
            }
        }
    }
})

Vue.prototype.$openrul = function (_url) {
    MyUtils.$router.navigateTo({
        url: _url
    })
}
Vue.prototype.$navigateBack = function () {
    MyUtils.$router.navigateBack()
}
Vue.prototype.$redirectTo = function (_url) {
    MyUtils.$router.redirectTo({
        url: _url
    })
}

Vue.config.productionTip = false
App.mpType = 'app'

const app = new Vue({
    MyStore,
    ...App
})

	// #ifdef H5
	if(MyConfig.mode == 1){
		//微信h5授权登录时使用此代码
		RouterMount(app,'#app');
	}else{
		app.$mount();
	}
	// #endif

	// #ifdef MP-WEIXIN
	//小程序授权登录时使用此代码
	app.$mount();
	// #endif






